<template>
  <el-card class="wisplm-card">
    <el-container>
      <el-main>
        <el-row :gutter="30">
          <el-col :span="6" v-for="(cardData, index) of cardDataList" :key="index" style="height: 100%">
            <el-card>
              <el-image @click="showInfo(cardData['id'], index)" slot="header" :src="cardData['img']" :fit="'fill'"
                        class="wisplm-card-img"/>
              <div class="el-row" @click="showInfo(cardData['id'], index)">
                <el-col class="wisplm-card-title" :span="24">{{ cardData['title'] }}</el-col>
                <el-col class="wisplm-card-content" :span="24">{{ cardData['content'] }}</el-col>
              </div>
            </el-card>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-button @click-="showMoreCard" type="text" class="wisplm-card-show-more">查看更多</el-button>
          </el-col>
        </el-row>
      </el-main>
      <el-dialog :visible.sync="showCardInfoFlag">
        <div>
          <div slot="header">
            <h1 class="wisplm-card-info-title">{{ selectedCardInfo['title'] }}</h1>
          </div>
          {{ selectedCardInfo['content'] }}
        </div>
      </el-dialog>
    </el-container>
  </el-card>
</template>

<script>
export default {
  name: "index",
  props: ['cardDataList'],
  data() {
    return {
      showCardInfoFlag: false,
      selectedCardInfo: {}
    }
  },
  methods: {
    showMoreCard() {
      this.$emit('showMoreCard')
    },
    showInfo(cardDataId, index) {
      this.showCardInfoFlag = true;
      this.selectedCardInfo = this.cardDataList[index]
    }
  }

}
</script>

<style scoped>
.wisplm-card {
  width: 100%;
  padding: 10px 0;
  margin-bottom: 10px;
}

.wisplm-card-img {
  width: 100%;
  height: 150px;
}

.wisplm-card-title {
  font-weight: bold;
  text-align: left;
  font-size: 30px;
}

.wisplm-card-content {
  font-size: initial;
  text-align: left;
}

.wisplm-card-show-more {
  color: #928f8f;
  width: 100%;
  margin-top: 15px;
}

.wisplm-card-info-title {
  font-size: 40px;
}
</style>
